set Loud Sound Threshold

Tell how loud it should be for your board to detect a loud sound.

input.setLoudSoundThreshold(0)

When the microphone hears a sound, it gives you a number for how loud the sound was at that moment. This number is the sound level and has a value from 0 (no sound) to 255 (very loud). You can use a sound level number as a threshold (just the right amount of sound) to make the on loud sound event happen.

Parameters

  • value: a sound level number which makes a loudness event happen.

Example

Flash the pixels to pink on the pixel strip when you clap or make another loud sound nearby.

let pixels = light.createStrip()
input.setLoudSoundThreshold(768)

input.onLoudSound(function() {
    pixels.setAll(0xff007f)
    pause(200)
    pixels.clear()
})

See also

on loud sound

microphone